  function [freqv,perv,edgew]=freq_vec(lb,ub,tt)
% ========================================================== 
% function [freqv,perv,edgew]=freq_vec(lb,ub,tt) 
% Given tt observations find the 
% data frequencies freqv and periods perv 
% associated with cycles of periodicty between lb and ub 
% GP and AJ 4/16/2005 
% Checked with the FFT frequencies in signal processing toolbnox 
% October 22 2007  Added EDGEW which gives the distance of the end bins to the 
%                  edges, in order to compute the approximation to the integral appropriately 
% See TEST_VARDECOMSPEC.m for details when comparing the 
% appropriate integral to that of a BP series 
% ============================================================
if lb > ub 
    tempub=lb; 
    lb=ub ; 
    ub=tempub; 
    clear tempub; 
end 
fer=1:floor((tt-1)/2); %Ensure that all frequencies < pi 
%fer=1:floor((tt)/2);
fer=(2*pi/tt)*fer; 
wlb=2*pi/ub;wub=2*pi/lb; 
freqv=fer(fer > wlb & fer < wub); 
perv=(2*pi)./(freqv); 
edgew=[(freqv(1)-wlb) (wub-freqv(end))];
if any( edgew > (freqv(2)-freqv(1)) );error('Lower bound widths defined incorrectly');end 